package com.test1225;

public class Test11 {
    public static void main(String[] args) {
        // 返回2个数组的交集
        int[] arr = {1,2,3,4,5};
        int[] brr = {3,4,5,6,7};
        int[] crr = m11(arr, brr);
        for (int c:crr) {
            System.out.println(c);
        }
    }
    public static int[] m11(int[] arr,int[] brr){
        int count =0;//交集个数
        for(int i=0;i<arr.length;i++){
            for(int j=0;j<brr.length;j++){
                if(arr[i]==brr[j]){
                    count++;
                }
            }
        }
        int[] newArJ =new int[count];
        int newIndex =0;
        for(int i=0;i<arr.length;i++){
            for(int j=0;j<brr.length;j++){
                if(arr[i]==brr[j]){
                    newArJ[newIndex]=arr[i];
                    newIndex++;
                }
            }
        }
        return newArJ;
    }
}
